home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d21 / qemmnote.arc / HEX.TEC < prev    next >
Text File  |  1991-06-26  |  9KB  |  251 lines

  1. ID:HX Hexadecimal Numbers and QEMM
  2. Quarterdeck Technical Note #190
  3. by Vernon Balbert
  4.  
  5.      Q:   Why are these numbers mixed up with these letters and
  6. what do
  7.      they mean?
  8.  
  9.      A:   These numbers and letters are part of a numbering system
  10. that is
  11.      used by computers.
  12.  
  13.           Computers don't count the way people do.  People use
  14. decimal, or
  15.      base 10 for counting and we use the numbers 0-9 giving us 10
  16. different
  17.      symbols for counting.  Computers, on the other hand, use
  18. binary, a
  19.      number system that uses just zeros and ones.  So, a typical
  20. binary
  21.      number might look like this:
  22.  
  23.                                 1001011011010010
  24.  
  25.           Kind of confusing, huh?  Well, even to programmers, these
  26. numbers
  27.      are confusing.  People just don't work well with binary. 
  28. Computers
  29.      do.  Binary numbers can be translated to decimal quite easily,
  30. but
  31.      they just aren't neat.  For instance, if you use an eight
  32. digit binary
  33.      number, you can count up to 255.  Well, this has three decimal
  34. numbers
  35.      and multiples of 256 (counting 0) is just not very neat or
  36. easy. 
  37.      However, there is a different way of counting that is widely
  38. used by
  39.      computer people.  This is called HEXADECIMAL.  Hexadecimal is
  40. base 16. 
  41.      What this means is that if you were to start counting from 0,
  42. you
  43.      would continue up to some single digit that would represent
  44. 15.  And
  45.      that's where the letters come from.  Hexadecimal numbers go
  46. like this:
  47.  
  48.                          0 1 2 3 4 5 6 7 8 9 A B C D E F
  49.  
  50.           Well, part of that looks normal, at least until the 9. 
  51. The A
  52.      translates as 10, the B as 11 on up until the F is equal to
  53. 15.  After
  54.      F, you tack on a 1 at the beginning of the number just like we
  55. do so
  56.      you would get 10.  And, yes, 10 plus 10 equal 20.  Since 10 in
  57. hexa-
  58.      decimal is equal to 16 in decimal, it would be logical to
  59. assume that
  60.      if 16+16=32 then 20 hexadecimal equals 32 decimal.  Rest
  61. assured, it
  62.      does.  Often, to tell the difference between hexadecimal and
  63. decimal
  64.      numbers, programmers will use H at the end of the number to
  65. say that
  66.      it is hexadecimal, i.e. 10H.  Now, if you have 8 binary
  67. numbers, you
  68.      can count either to 256, or to FFH.  (Remember, the H stands
  69. for
  70.      hexadecimal.)  This means that you can count in multiples of
  71. 4 binary
  72.      digits with one hexadecimal digit.  For instance:
  73.  
  74.                             10010110=96H=150 base 10
  75.  
  76.           Now, you might ask, why use multiples of 4 binary digits? 
  77. Well,
  78.      the answer is really quite simple.  Computer people like to
  79. group
  80.      binary numbers in groups of eight.  A hexadecimal number can
  81. represent
  82.      4 binary digits.  Each number is called a bit and each group
  83. of eight
  84.      bits is a byte.  And computer memory is measured in bytes. 
  85. Each byte
  86.      can represent one character such as the letter "Q" or the
  87. number "3". 
  88.      Your hard disk is measured in megabytes, or millions of bytes. 
  89. So,
  90.  
  91.      hexadecimal is a number system that both computers and humans
  92. can work
  93.      with easily.  Actually, computers don't work with hexadecimal,
  94. but
  95.      most programs that work with hexadecimal numbers have routines
  96. that
  97.      translate the hexadecimal numbers to binary for the computer
  98. because
  99.      it's so easy; simply convert each hex digit into the
  100. appropriate 4
  101.      binary digits.  By the way, hexadecimal is often referred to
  102. as "hex"
  103.      for short.
  104.  
  105.           Okay, now we have to delve a little into the history of
  106. IBM PCs
  107.      to understand the way you address memory.
  108.  
  109.           When IBM first came out with the PC, the Intel 8088
  110. processor was
  111.      used.  The 8088 can access 1 megabyte of memory.  However, the
  112. chip
  113.      only has 16 bit registers.  (A register is an internal memory
  114. loca-
  115.      tion.)  You can only count to 65535 with 16 bits.  In order to
  116. access
  117.      the 20 bits outside the microprocessor, an alternate method of
  118. ad-
  119.      dressing memory was developed.  So, addresses had the
  120. following
  121.      format:
  122.  
  123.                                     ssss:oooo
  124.  
  125.           The first four hex digits (ssss) are the segment address. 
  126. The
  127.      last four (oooo) are the offset address.  Together, these can
  128. address
  129.      the entire 1 megabyte space of the 8088.  This is called
  130. relative
  131.      addressing.  You never actually say the exact address that you
  132. are
  133.      pointing at, just an address relative to a different position. 
  134. For
  135.      instance, if you have an address such as 1234:2319, you would
  136. take
  137.      1234H, add a 0 to the end so it turns into 12340H and then add
  138. 2319H
  139.      to it to get 14659H.
  140.  
  141.           When the 80286 came out, it had 24 address lines to
  142. address more
  143.      than the 1 megabyte of memory available.  (24 address lines
  144. lets you
  145.      address 16 megabytes of memory.)  Additionally, the internal
  146. registers
  147.      were enlarged to 24 bits so you didn't have to go through the
  148. segment
  149.      and offset gyrations.  So, you could now use absolute
  150. addressing.  The
  151.      address now takes this format:
  152.  
  153.                                      XXXXXX
  154.  
  155.           Notice now, that there are 6 digits instead of two sets
  156. of 4 when
  157.      an 80286 is in "protected" mode (6 digit mode).  DOS,
  158. unfortunately,
  159.      only understands segmented memory addressing which is in
  160. "real" mode. 
  161.      Intel built in a "real" mode into the 80286 and higher
  162. processors so
  163.      that they would still understand relative addressing.  This
  164. difference
  165.      is VERY important.  It is the main reason that you can't use
  166. exTENDed
  167.      memory (only available in "protected" mode) to run DOS
  168. programs (which
  169.      require "real" mode). 
  170.  
  171.           QEMM, QRAM and DESQview all observe the relative
  172. addressing
  173.      scheme.  So, when you include or exclude areas of memory with
  174. QEMM,
  175.      you use the segment address.  Typically, the only exclusions
  176. you will
  177.      use involve the area above the 640K program space.  This is a
  178. 384K
  179.      area of memory that is normally used by adapter cards and ROMs
  180. in your
  181.      computer.  The address range of the lower 640K is 0000-9FFF. 
  182. Remem-
  183.  
  184.      ber, these are the segment addresses, not the offset
  185. addresses.  The
  186.      area above 640K is the A000-FFFF range.
  187.  
  188.      Here is a translation table so you can convert some common
  189. hexadecimal
  190.      addresses into decimal and back.
  191.  
  192.         Common way of saying it    Decimal Hexadecimal         
  193. Segment:Offset
  194.                              1K       1024         400  0040:0000
  195. or 0000:0400
  196.                              2K       2048         800  0080:0000
  197. or 0000:0800
  198.                              4K       4096        1000  0100:0000
  199. or 0000:1000
  200.                              8K       8192        2000  0200:0000
  201. or 0000:2000
  202.                             16K      16384        4000  0400:0000
  203. or 0000:4000
  204.                             32K      32768        8000  0800:0000
  205. or 0000:8000
  206.                             64K      65536       10000            
  207.   1000:0000
  208.                            128K     131072       20000            
  209.   2000:0000
  210.                            256K     262144       40000            
  211.   4000:0000
  212.                            384K     393612       60000            
  213.   6000:0000
  214.                            512K     524288       80000            
  215.   8000:0000
  216.                            640K     655350       A0000            
  217.   A000:0000
  218.                            704K     720896       B0000            
  219.   B000:0000
  220.                            736K     753664       B8000            
  221.   B800:0000
  222.                            768K     786432       C0000            
  223.   C000:0000
  224.                            832K     851968       D0000            
  225.   D000:0000
  226.                            896K     917504       E0000            
  227.   E000:0000
  228.                            960K     983040       F0000            
  229.   F000:0000
  230.                           1024K    1048576      100000  1MB and
  231. beyond cannot
  232.                                                         be
  233. addressed with the
  234.                                                        
  235. segment:offset method.
  236.  
  237.      In summary, we see that hexadecimal (or hex, for short) is
  238. actually
  239.      base 16, decimal is base 10 and binary is base 2.  Hex numbers
  240. go from
  241.      0 to F, decimal numbers go from 0 to 9 and binary go from 0 to
  242. 1.  Hex
  243.      numbers are used to make it easier for people to work with
  244. numbers
  245.      that the computer uses.
  246.  
  247.              Copyright (C) 1991 by Quarterdeck Office Systems
  248.                   * * *   E N D   O F   F I L E    * * * 
  249.  
  250.  
  251.